/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package config.Models;

import config.ConfigMacros;
import java.util.Map;
import libCore.Util;
/**
 *
 * @author LinhTA
 */
public class Conf_PegLevel {
    
    public Eat eat;
    public Sell sell;
    public BuyExp buyExp;
    public long timeSpawn;
    public String egg;
    
    public Conf_PegLevel(Map<String,Object> obj)
    {
        eat = new Eat(Util.obj2Map(obj.get(ConfigMacros.PEG_LEVELS_EAT)));
        sell = new Sell(Util.obj2Map(obj.get(ConfigMacros.PEG_LEVELS_SELL)));
        buyExp = new BuyExp(Util.obj2Map(obj.get(ConfigMacros.PEG_LEVELS_BUYEXP)));
        
        if(obj.containsKey(ConfigMacros.PEG_LEVELS_TIMESPAW))
        {
            long spawn       =   Long.parseLong(obj.get(ConfigMacros.PEG_LEVELS_TIMESPAW).toString());
            if( spawn != -1)
                timeSpawn = spawn * 1000;
            else timeSpawn  =   -1;
        }
        
        if(obj.containsKey(ConfigMacros.PEG_LEVELS_EGG))
            egg = obj.get(ConfigMacros.PEG_LEVELS_EGG).toString();
        else
            egg = "";
    }
    
    public class Eat
    {
        public int feed;
        public int timeHungry;
        public int exp;
        
        public Eat(Map<String,Object> obj)
        {
            feed = Integer.parseInt(obj.get(ConfigMacros.PEG_LEVELS_EAT_FEED).toString());
            timeHungry = Integer.parseInt(obj.get(ConfigMacros.PEG_LEVELS_EAT_HUNGRY).toString()) * 1000;
            exp = Integer.parseInt(obj.get(ConfigMacros.PEG_LEVELS_EAT_EXP).toString());
        }
    }
    
    public class Sell
    {
       public int gold;
       
        public Sell(Map<String,Object> obj)
        {
            gold = Integer.parseInt(obj.get(ConfigMacros.GOLD).toString());
        }
    }
     
    public class BuyExp
    {
        public int coin;
        public int exp;
        
        public BuyExp(Map<String,Object> obj)
        {
            coin = Integer.parseInt(obj.get(ConfigMacros.PEG_LEVELS_BUYEXP_COIN).toString());
            exp = Integer.parseInt(obj.get(ConfigMacros.PEG_LEVELS_BUYEXP_EXP).toString());
        }
    }
}
